//
//  ThemeSize.h
//  FM_CZFW
//
//  界面相关尺寸宏定义
//
//  Created by Lang on 14-4-1.
//  Copyright (c) 2014年 ETelecom. All rights reserved.
//

#ifndef ThemeSize_h
#define ThemeSize_h

/*
 *  主窗口
 */
#define HUIKeyWindow                [UIApplication sharedApplication].keyWindow
#define HUITopWindow                [[[UIApplication sharedApplication] windows] lastObject]

/*
 * 字体
 */
#define kICON_FONT_NAME             @"iconfont"

#define kFONT_SYS_22                [UIFont systemFontOfSize:22]
#define kFONT_SYS_18                [UIFont systemFontOfSize:18]
#define kFONT_SYS_16                [UIFont systemFontOfSize:16]
#define kFONT_SYS_15                [UIFont systemFontOfSize:15]
#define kFONT_SYS_14                [UIFont systemFontOfSize:14]
#define kFONT_SYS_13                [UIFont systemFontOfSize:13]
#define kFONT_SYS_12                [UIFont systemFontOfSize:12]
#define kFONT_SYS_11                [UIFont systemFontOfSize:11]
#define kFONT_SYS_10                [UIFont systemFontOfSize:10]


#define kFONT_MID_24                [UIFont systemFontOfSize:24 weight:UIFontWeightMedium]
#define kFONT_MID_22                [UIFont systemFontOfSize:22 weight:UIFontWeightMedium]
#define kFONT_MID_20                [UIFont systemFontOfSize:20 weight:UIFontWeightMedium]
#define kFONT_MID_18                [UIFont systemFontOfSize:18 weight:UIFontWeightMedium]
#define kFONT_MID_17                [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]
#define kFONT_MID_16                [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
#define kFONT_MID_15                [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]
#define kFONT_MID_14                [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]
#define kFONT_MID_13                [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]
#define kFONT_MID_12                [UIFont systemFontOfSize:12 weight:UIFontWeightMedium]

/*
 *  屏幕适配
 */
#define kNAVBAR_HEIGHT              44
#define kTABAR_HRIGHT               49
#define kSTATUSBAR_HRIGHT           ([UIApplication sharedApplication].statusBarFrame.size.height)
#define kNAV_STATUS_HEIGHT          (kNAVBAR_HEIGHT + kSTATUSBAR_HRIGHT)

// 底部安全区域的边界
#define kSAFE_BOTTOM_HEIGHT         (iPhoneX_R ? 34 : 0)

// 屏幕frame
#define HUIApplicationFrame()       ([UIScreen mainScreen].bounds)

// Base视图TableView中的 RECT
#define kBASE_TABLEVIEW_RECT        CGRectMake(0, 0, kPRO_SCREEN_WIDTH, KPRO_SAFE_VIEW_HEIGHT - kNAV_STATUS_HEIGHT)

#define kPRO_SCREEN_WIDTH           [UIScreen mainScreen].bounds.size.width     // 屏幕宽
#define KPRO_SCREEN_HEIGHT          [UIScreen mainScreen].bounds.size.height    // 屏幕高
#define KPRO_SAFE_VIEW_HEIGHT       ([UIScreen mainScreen].bounds.size.height - kSAFE_BOTTOM_HEIGHT)     // SafeArea屏幕高

#define SIGLE_LINE_HEIGHT           (1/[UIScreen mainScreen].scale) // 横线高度

#define KVIEW_BOUNDS_WIDTH          self.view.bounds.size.width     // 当前view的宽
#define KVIEW_BOUNDS_HEIGHT         self.view.bounds.size.height    // 当前view的高

#define KLEFT_SLIDEVIEW_WIDTH       (kPRO_SCREEN_WIDTH * 0.7)       // 左滑抽屉宽度

#define kBANNER_HEIGHT              (([UIScreen mainScreen].bounds.size.width-30)*10/23.0)
#define kSearchH                    (([UIScreen mainScreen].bounds.size.width/9<40)?40:[UIScreen mainScreen].bounds.size.width/9.5)

#define iPhoneX_R ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? ((NSInteger)(([[UIScreen mainScreen] currentMode].size.height/[[UIScreen mainScreen] currentMode].size.width)*100) == 216) : NO)

/*
 #define iPhoneX_R \
 ({BOOL isPhoneX = NO;\
 if (@available(iOS 11.0, *)) \
     isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
 (isPhoneX);})
 */


#define autoSizeScaleX          KPRO_SCREEN_HEIGHT > 480 ? (CGFloat)kPRO_SCREEN_WIDTH / 320.0f : 1
#define autoSizeScaleY          KPRO_SCREEN_HEIGHT > 480 ? (CGFloat)KPRO_SCREEN_HEIGHT / 568.0f : 1

///检测是否是iPhone X
#define WF_ISIPHONEX  KPRO_SCREEN_HEIGHT>=812?YES:NO

// 320像素窄屏幕

#define KNARROW_SCREEN  ((kPRO_SCREEN_WIDTH<350)?YES:NO)

CG_INLINE CGFloat
WFCGFloatX(CGFloat num) {
    CGFloat scalex = autoSizeScaleX;
    CGFloat xnum = num * scalex;
    return xnum;
}

CG_INLINE CGFloat
WFCGFloatBackX(CGFloat num) {
    CGFloat scalex = autoSizeScaleX;
    CGFloat xnum = num / scalex;
    return xnum;
}

CG_INLINE CGFloat
WFCGFloatY(CGFloat num) {
    CGFloat scaley;
    if (WF_ISIPHONEX) {
        scaley = autoSizeScaleX;
    }else{
        scaley = autoSizeScaleY;
    }
    CGFloat ynum = num * scaley;
    return ynum;
}

CG_INLINE CGFloat
WFCGFloatBackY(CGFloat num) {
    CGFloat scaley;
    if (WF_ISIPHONEX) {
        scaley = autoSizeScaleX;
    }else{
        scaley = autoSizeScaleY;
    }
    CGFloat ynum = num / scaley;
    return ynum;
}

CG_INLINE CGRect
WFCGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGRect rect;
    CGFloat scalex = autoSizeScaleX;
    CGFloat scaley;
    if (WF_ISIPHONEX) {
        scaley = autoSizeScaleX;
    }else{
        scaley = autoSizeScaleY;
    }
    CGFloat xx = x * scalex;
    CGFloat yy = y * scaley;
    CGFloat wwidth = width * scalex;
    CGFloat hheight = height * scaley;
    rect = CGRectMake(xx, yy, wwidth, hheight);
    return rect;
}
CG_INLINE CGPoint
WFCGPointMake(CGFloat x, CGFloat y)
{
    CGPoint point;
    CGFloat scalex = autoSizeScaleX;
    CGFloat scaley;
    if (WF_ISIPHONEX) {
        scaley = autoSizeScaleX;
    }else{
        scaley = autoSizeScaleY;
    }
    CGFloat xx = x * scalex;
    CGFloat yy = y * scaley;
    point = CGPointMake(xx, yy);
    return point;
}
CG_INLINE CGSize
WFCGSizeMake(CGFloat width, CGFloat height)
{
    CGSize size;
    CGFloat scalex = autoSizeScaleX;
    CGFloat scaley;
    if (WF_ISIPHONEX) {
        scaley = autoSizeScaleX;
    }else{
        scaley = autoSizeScaleY;
    }
    CGFloat wwidth = width * scalex;
    CGFloat hheight = height * scaley;
    size = CGSizeMake(wwidth, hheight);
    return size;
}


/**************************  项目中用到的自定义高度  ***************************/
/** 课程图片宽高比例  */
static CGFloat const CourseCoverImageRadio = 41/75.0;

/** 首页 banner宽高比例  */
static CGFloat const HomeMainBannerRadio = 17/30.0;

#endif
